import random

from util.ip666 import get_long_ip, get_one_ip
import requests

proxies = get_long_ip(3)

urls = [f"https://httpbin.org/get?a={i}" for i in range(100)]
for url in urls:
    proxy = random.choice(proxies)

    try:
        res = requests.get(url, proxies=proxy)
        print(res.json())
    except requests.exceptions.RequestException as e:
        print("代理错误，从新获取")
        proxies.remove(proxy)
        proxies.append(get_one_ip())
    except Exception as e:
        print("未知错误")
